package com.blood.core.config.mybatisplus;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @author yelong
 * @date2020/07/25 11:18
 * @description
 * @Copyright
 */
public class ICommonServiceImpl<M extends ICommonMapper<T>, T> extends ServiceImpl<M, T> implements ICommonService<T> {
    @Override
    public boolean deleteById(String id) {
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return super.remove(wrapper);
    }

    @Override
    public boolean updateById(T entity, String id) {
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return super.update(entity, wrapper);
    }

    @Override
    public T findById(String id) {
        QueryWrapper<T> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        T pos = getOne(wrapper);
        return pos;
    }
}
